import 'package:flutter/material.dart';
import 'package:visibility_detector/visibility_detector.dart';

/**
 * @title 监听组件是否可见
 * @info  进入后台，前台不会执行
 */
Widget FFSeeWidget({
  required Key key,
  required Widget child,
  required Function(bool show) onShow,
}) {
  return VisibilityDetector(
    key: key,
    onVisibilityChanged: (visibilityInfo) {
      onShow(visibilityInfo.visibleFraction > 0.5);
    },
    child: child,
  );
}
